home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Otherware
/
Otherware_1_SB_Development.iso
/
mac
/
hypercar
/
xfcn
/
spttool.cpt
/
Support Tools eXternals 1.2.5
/
card_40319.txt
< prev
next >
Wrap
Text File
|
1990-11-13
|
11KB
|
313 lines
-- card: 40319 from stack: in.5
-- bmap block id: 44867
-- flags: 0000
-- background id: 3858
-- name: SCSIIDToName
----- HyperTalk script -----
on CloseCard
put empty into cd fld "ids"
put empty into cd fld "volumes"
pass CloseCard
end CloseCard
on HideObjects
hide cd fld "label"
hide cd fld "volumes"
hide cd fld "ids"
hide cd btn "try it!"
end HideObjects
on ShowObjects
show cd fld "label"
show cd fld "volumes"
show cd fld "ids"
show cd btn "try it!"
end ShowObjects
-- part 2 (field)
-- low flags: 00
-- high flags: 0002
-- rect: left=71 top=147 right=294 bottom=255
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: volumes
-- part 3 (field)
-- low flags: 00
-- high flags: 0002
-- rect: left=19 top=147 right=294 bottom=72
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: ids
-- part 4 (button)
-- low flags: 00
-- high flags: A002
-- rect: left=78 top=302 right=336 bottom=171
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 8192
-- line height: 16
-- part name: Try it!
----- HyperTalk script -----
on mouseUp
global errGlobal
put empty into cd fld "ids"
put empty into cd fld "volumes"
repeat with driveNdx = 0 to 6
put SCSIIDToName(driveNdx, "noDialog:errGlobal") into driveName
if errGlobal Γëá empty then
answer "Error at ID" && driveNdx & ":" &&errGlobal
put empty into errGlobal
else
put driveNdx into line driveNdx + 1 of cd fld "ids"
put driveName into line driveNdx + 1 of cd fld "volumes"
end if
end repeat
end mouseUp
-- part 5 (field)
-- low flags: 00
-- high flags: 0000
-- rect: left=16 top=129 right=145 bottom=252
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: label
-- part contents for background part 38
----- text -----
40/50
-- part contents for card part 5
----- text -----
SCSI ID SCSI Drive Name
-- part contents for background part 20
----- text -----
An XFCN which returns the name of a SCSI drive at a specified SCSI ID.
Calling syntax : SCSIIDToName(SCSI ID#,<ΓÇ£noDialogΓÇ¥:errorGlobal>)
SCSI ID#: the SCSI ID number (between 0 and 6) to check.
NOTE: If a drive has been partitioned, then only the name of the first partition will be returned.
-- part contents for background part 42
----- text -----
unit SCSIDToIName;
{ SCSIDToIName(diskNumber, ΓÇ£noDialog:ΓÇ¥errorGlobal) }
{ XFCN returns the name of a SCSI disk given it's ID }
{}
{ brought to you by: Anup Murarka Eric Carlson }
{ ALINK: SKEPTIC ALINK: cyNic }
{ CIS: 76004,3356 }
{}
{ We are part of the Support Tools Development Group, }
{ Apple Computer, Inc. }
{}
{ please DO NOT contack Mac DTS for support of this code! }
{}
{ please DO contact the authors for support of this code! }
{}
{ Send comments, bug reports, requests to any of the above }
{ E-mail addresses or to:}
{}
{ (one of us) }
{ Apple Computer, Inc. }
{ 900 E. Hamilton, Ave. }
{ Campbell, CA 95008 }
{ M/S 72-L }
{}
{ Copyright: © 1989, 1990 by Apple Computer, Inc., all rights reserved. }
{}
{ written by Eric Carlson }
{ AppleLink: cyNic }
{ modification history }
{ Date Initials Comments }
{ ---- ------ ---------------------------------------------------}
{ 1/5/90 ec first written }
{ 2/26/90 ec added new "askedForHelp" }
{ 4/25/90 ec fixed bug when passed name of a non SCSI disk }
{ 5/25/90 ec modified for A/UX compatibility. changed name from }
{ ΓÇ£SCSINameΓÇ¥ to ΓÇ£SCSIIDToNameΓÇ¥. changed version to }
{ 1.1}
{}
interface
uses
HyperXCMD;
procedure MAIN (paramPtr: XCmdPtr);
implementation
procedure reportToUser (paramPtr: XCmdPtr;
msgStr: str255);
{}
{ report something back to the user. }
{ the last parameter (optional) to an external may contain }
{ "noDialog" or "noDialog:GlobalName". GlobalName is the name }
{ of a HyperTalk global variable into which error messages will be }
{ placed. we've decided to use this approach to avoid confusing }
{ an error message with a valid result being returned from an XFCN. }
{}
var
tempStr: str255;
begin
{check the last param to see if the user requested that}
{ we suppress the error dialog }
ZeroToPas(paramPtr, paramPtr^.params[paramPtr^.paramCount]^, tempStr);
UprString(tempStr, true);
if pos('NODIALOG', tempStr) = 0 then
{ no special error handling specified, throw up a dialog and return the error message }
begin
SendCardMessage(paramPtr, concat('answer "', msgStr, '"'));
paramPtr^.returnValue := PasToZero(paramPtr, msgStr);
end
else if (pos(':', tempStr) > 0) then
{ requested global AND noDialog so we fill in the global and return empty }
begin
tempStr := copy(tempStr, pos(':', tempStr) + 1, length(tempStr));
{ get the name of the HC global to fill }
SetGlobal(paramPtr, tempStr, PasToZero(paramPtr, msgStr));
{ and fill it }
paramPtr^.returnValue := PasToZero(paramPtr, ''); { return empty }
end
else
{ requested noDialog only so we return the error condition as the result }
paramPtr^.returnValue := PasToZero(paramPtr, msgStr);
end; { procedure }
function AskedForHelp (paramPtr: XCmdPtr;
syntaxMsg: Str255;
copyrightMsg: Str255): boolean;
{ check to see if the user sent a '?' or a '!' as }
{ the only parameter. if so we will respond with }
{ the calling syntax or the copyright/version info }
{ for this external }
{}
var
firstStr: str255;
begin
askedForHelp := false;
if paramPtr^.paramCount = 1 then
begin
ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr);
{ what is the first param? }
if firstStr = '?' then
begin
reportToUser(paramPtr, syntaxMsg);
askedForHelp := true
end { asked for help }
else if firstStr = '!' then
begin
reportToUser(paramPtr, copyRightMsg);
askedForHelp := true
end; { asked for copyright info }
end; { one parameter passed }
end; { function }
function LongToString (paramPtr: XCmdPtr;
num: LONGINT): Str255;
{ why, oh why did dan write this one as a procedure??? }
var
tempStr: str255;
begin
LongToStr(paramPtr, num, tempStr);
LongToString := tempStr;
end;
function BitTest (AddressToCheck: ptr;
TotalBits: integer;
BitToTest: longint): boolean;
{ function that allows caller to use std. 68000 bit notation instead of the Toolbox's reversed notation}
{ example: bit 0 (the least significant bit) in a byte is bit 7 in the Toolbox's notation}
begin
BitTest := BitTst(AddressToCheck, TotalBits - 1 - BitToTest);
end;
function AUXisRunning: boolean;
const
HWCfgFlag = $0B22;
begin
AUXisRunning := BitTest(pointer(HWCfgFlag), 16, 9);
end;
procedure SCSIName (paramPtr: XCmdPtr);
{ the BITNOT of a driver's ref num is it's number in the unit table. in the case of a driver for a SCSI disk the entry }
var
tempStr, volName: str255;
requestedSCSIID: integer;
PB: HParamBlockRec;
volInfoErr: OSErr;
done: boolean;
begin
if askedForHelp(paramPtr, 'SCSIIDToName(SCSI ID#,<“noDialog”:errorGlobal>)', '© 1989 Apple Computer, Inc. v.1.1, bu Eric Carlson.') then
exit(SCSIName);
if paramPtr^.paramCount < 1 then { we need the disk name to search for }
begin
reportToUser(paramPtr, 'SCSI ID expected');
exit(SCSIName)
end;
ZeroToPas(paramPtr, paramPtr^.params[1]^, tempStr);
requestedSCSIID := StrToNum(paramPtr, tempStr);
if (requestedSCSIID < 0) or (requestedSCSIID > 6) then { an illegal SCSI ID# }
begin
reportToUser(paramPtr, 'SCSI ID must be > 0 and < 7.');
exit(SCSIName)
end;
zeroBytes(paramPtr, @PB, sizeOf(PB)); { start out with a clean paramblock }
PB.ioNamePtr := @volName;
PB.ioVolIndex := 0;
done := false;
repeat
PB.ioVolIndex := PB.ioVolIndex + 1; { next volume }
volInfoErr := PBHGetVInfo(@PB, false); { get the next volume name }
if volInfoErr = noErr then { see if we're done yet }
if BITNOT(PB.ioVDRefNum) - 32 = requestedSCSIID then
done := true;
{ the trick here is that the BITNOT of a drive's ioVDRefNum is equal to its number in the unit table, }
{ which is it's SCSI id + 32 }
until (volInfoErr <> noErr) or (done);
if volInfoErr <> noErr then { return empty if no disk mounted }
volName := ''
else
volName := concat(volName, ':');
paramPtr^.returnValue := PasToZero(paramPtr, volName); { return the drive name }
end; { procedure SCSIName}
procedure MAIN (paramPtr: XCmdPtr);
begin
SCSIName(paramPtr);
end;
end. { unit SCSIName}